<?php

namespace App\Cost;

class MinutesCost extends AbstractCost
{
    /**
     * 每分钟收费价格
     * @var int
     */
    public int $perMinutesPrice = 0;

    protected function getCost(string $startTime, string $endTime): Price
    {
        //分钟数
        $minutes = (int)((strtotime($endTime) - strtotime($startTime)) / 60);

        $basePrice = $this->perMinutesPrice * $minutes;

        return new Price($basePrice);
    }

    protected function getPricePerMinutes(): float
    {
        return $this->perMinutesPrice;
    }

    public function getPerMinutesPrice(): float|null
    {
        return $this->getPricePerMinutes() / 100;
    }
}
